package com.zwr.sheller.shop.service.impl;

import com.zwr.sheller.core.pojo.Gifts;
import com.zwr.sheller.shop.mapper.GiftsMapper;
import com.zwr.sheller.shop.service.GiftsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 *
 *@author Kang
 *@date
 */
@Service("giftsService")
public class GiftsServiceImpl implements GiftsService {

    @Autowired(required = false)
    GiftsMapper giftsMapper;

    @Override
    public Integer add(Gifts gifts) {
        Long marketersId = 1L;
        gifts.setMarketersId(marketersId);
        int insert = giftsMapper.insert(gifts);
        return insert;
    }

    @Override
    public Integer delete(Long id) {

        Gifts gifts=new Gifts();
        gifts.setId(id);


        int delete = giftsMapper.delete(gifts);
        return delete;
    }

    @Override
    public Integer update(Gifts gifts) {

        int i = giftsMapper.updateByPrimaryKeySelective(gifts);
        return i;
    }

    @Override
    public List<Map<String, Object>> selectGiftsByNameByTimeByManner(Integer manner, Integer timePeriod, String name, Integer page) {
        Long marketersId = 1L;
        List<Map<String, Object>> mapList = giftsMapper.selectGiftsByNameByTimeByManner(manner, timePeriod, name, marketersId, (page - 1) * 3);
        return mapList;
    }

    @Override
    public Map selectGiftsByNameByTimeByMannerCount(Integer manner, Integer timePeriod, String name) {
        Long marketersId = 1L;
        Map map = giftsMapper.selectGiftsByNameByTimeByMannerCount(manner, timePeriod, name, marketersId);
        return map;
    }
}
